
#include "stdafx.h"
#include "Lights.h"
#include <iostream>
#include "vec.h"
//#include "color.h"

using namespace std;

static void readLightComponents(vec3 & amb, vec3 & diff, vec3 & spec) {
	cout << "Please enter AMBIENT light components (R,G,B): ";
	cin >> amb.x >> amb.y >> amb.z;
	cout << "Please enter DIFFUSE  light components (R,G,B): ";
	cin >> diff.x >> diff.y >> diff.z;
	cout << "Please enter SPECULAR light components (R,G,B): ";
	cin >> spec.x, spec.y, spec.z;
}
/*--------------------    LIGHT SOURCE   ---------------------------------------------------------------------------*/
LightSource::~LightSource(){}

LightSource::LightSource(const vec3& ambient, const vec3 & diffuse, const vec3 specular)
:m_ambientIntensity(ambient),m_diffuseIntensity(diffuse), m_specularIntensity(specular)
{
}
/*--------------------    LIGHT SOURCE   ---------------------------------------------------------------------------*/
/*--------------------    AMBIENT LIGHT SOURCE   ---------------------------------------------------------------------------*/
/*--------------------    AMBIENT LIGHT SOURCE   ---------------------------------------------------------------------------*/
/*--------------------    POINT LIGHT SOURCE   ---------------------------------------------------------------------------*/
PointLightSource::PointLightSource(const vec3& ambient, const vec3& diffuse, const vec3& specular,const vec4& location)
:LightSource(ambient,diffuse,specular),m_location(location){}

vec3 PointLightSource::getHitDirection(const vec4 & p) const {
	return vec3(m_location.x - p.x, m_location.y - p.y, m_location.z - p.z);
}


PointLightSource * readPointLightSource(){
	vec3 amb, diff, spec;
	vec4 location;
	location.w = 1;
	readLightComponents(amb,diff,spec);
	cout << "Please enter location of the light source (x,y,z): ";
	cin >> location.x >> location.y >> location.z;
	return new PointLightSource(amb,diff,spec,location);
}

void PointLightSource::translateLocation(const GLfloat & x,const GLfloat & y,const GLfloat & z) const{
	//this->m_location = this->m_location + vec4(x,y,z,0);
	cout<<"new location = FIXFIXFIXFIX  "<<m_location<<endl;
}
/*--------------------    POINT LIGHT SOURCE   ---------------------------------------------------------------------------*/
/*--------------------    PARALLEL LIGHT SOURCE   ---------------------------------------------------------------------------*/
ParallelLightSource::ParallelLightSource(const vec3& ambient, const vec3& diffuse, const vec3& specular,
	const vec3& direction):LightSource(ambient,diffuse,specular),m_direction(direction){}


vec3 ParallelLightSource::getHitDirection(const vec4 & p) const {
	return VEC4TOVEC3(m_direction);
}


ParallelLightSource * readParallelLightSource() {
	vec3 amb, diff, spec;
	vec3 direction;
	readLightComponents(amb,diff,spec);
	cout << "Please enter the direction of the light source  (x,y,z): ";
	cin >> direction.x >> direction.y >> direction.z;
	return new ParallelLightSource(amb,diff,spec,direction);
}
/*--------------------    PARALLEL LIGHT SOURCE   ---------------------------------------------------------------------------*/